﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:Controls="clr-namespace:Twedge.Controls" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="Twedge.MainPage"
    mc:Ignorable="d"
             
    d:DesignHeight="300" d:DesignWidth="200">
	<UserControl.Resources>
        <Style x:Key="FluidItemsControlItemStyle"
               TargetType="Controls:FluidItemsControlItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Controls:FluidItemsControlItem">
                        <ContentPresenter x:Name="contentPresenter"
                    		ContentTemplate="{TemplateBinding ContentTemplate}"
                    		Content="{TemplateBinding Content}"
                    		HorizontalAlignment="Stretch" Opacity="0">
                        	<ContentPresenter.Projection>
                        		<PlaneProjection RotationX="90" CenterOfRotationX="0" CenterOfRotationY="0"/>
                        	</ContentPresenter.Projection>
                    		<VisualStateManager.VisualStateGroups>
                    			<VisualStateGroup x:Name="LayoutStates">
                    				<VisualState x:Name="BeforeLoaded"/>
                    				<VisualState x:Name="AfterLoaded">
                    					<Storyboard>
                    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="contentPresenter">
                    							<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="90"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:1.2"
                                                                      Value="0">
                                                    <EasingDoubleKeyFrame.EasingFunction>
                                                        <ElasticEase EasingMode="EaseOut"
                                                                     Oscillations="1"
                                                                     Springiness="2" />
                                                    </EasingDoubleKeyFrame.EasingFunction>
                                                </EasingDoubleKeyFrame>
                                            </DoubleAnimationUsingKeyFrames>
                    						<DoubleAnimation BeginTime="0:0:0.4" Duration="0:0:0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True"/>
                    					</Storyboard>
                    				</VisualState>
                    				<VisualState x:Name="BeforeUnloaded"/>
                    			</VisualStateGroup>
                    		</VisualStateManager.VisualStateGroups>
                    	</ContentPresenter>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
			<StackPanel>
				<i:Interaction.Behaviors>
					<ei:FluidMoveBehavior AppliesTo="Children" Duration="0:0:0.5" >
						<ei:FluidMoveBehavior.EaseY>
							<QuadraticEase EasingMode="EaseInOut"/>
						</ei:FluidMoveBehavior.EaseY>
					</ei:FluidMoveBehavior>
				</i:Interaction.Behaviors>
			</StackPanel>
		</ItemsPanelTemplate>
	</UserControl.Resources>
    <Border BorderThickness="1" Padding="0">
        <Border.Background>
            <SolidColorBrush Color="{Binding BackgroundColor, Source={StaticResource Theme}}" />
        </Border.Background>
        <Border.BorderBrush>
            <SolidColorBrush Color="{Binding BorderColor, Source={StaticResource Theme}}" />
        </Border.BorderBrush>
        <Grid x:Name="LayoutRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <!--<ScrollViewer VerticalScrollBarVisibility="Auto" 
                          HorizontalScrollBarVisibility="Disabled">-->
            <Controls:FluidItemsControl ItemsSource="{Binding Statuses}" ItemsPanel="{StaticResource ItemsPanelTemplate}" ItemContainerStyle="{StaticResource FluidItemsControlItemStyle}">
                <Controls:FluidItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border>
                            <Border.Background>
                                <SolidColorBrush Color="{Binding BackgroundColor}" />
                            </Border.Background>
                            <!--<Border BorderBrush="Black" BorderThickness="0,0,0,1">-->
                                <Grid Margin="2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <HyperlinkButton NavigateUri="{Binding AuthorUri}"
                                                     HorizontalAlignment="Left"
                                                     VerticalAlignment="Top"
                                                     TargetName="_blank">
                                        <Image Width="50"
                                               Height="50"
                                               Margin="0,4,0,0"
                                               Stretch="Uniform"
                                               Source="{Binding PhotoUri}" />
                                    </HyperlinkButton>
                                    <Controls:HtmlTextBlock Text="{Binding Title}"
                                                            Background="{x:Null}"
                                                            Foreground="{Binding ForegroundColor, Source={StaticResource Theme}}"
                                                            Grid.Column="1"
                                                            Margin="2,0,0,0" />
                                    <StackPanel Orientation="Horizontal"
                                                Grid.Row="2"
                                                Grid.ColumnSpan="2"
                                                Margin="0,2,0,0">
                                    <HyperlinkButton NavigateUri="{Binding AuthorUri}"
                                                     Content="{Binding Author}"
                                                     TargetName="_blank">
                                        <HyperlinkButton.Foreground>
                                            <SolidColorBrush Color="{Binding UsernameColor, Source={StaticResource Theme}}" />
                                        </HyperlinkButton.Foreground>
                                    </HyperlinkButton>
                                    <TextBlock Margin="2,0,0,0"
                                               Text="{Binding Published, StringFormat=d.M. H:mm}">
                                        <TextBlock.Foreground>
                                            <SolidColorBrush Color="{Binding TimeColor, Source={StaticResource Theme}}" />
                                        </TextBlock.Foreground>
                                    </TextBlock>
                                </StackPanel>
                                </Grid>
                            </Border>
                        </DataTemplate>
                </Controls:FluidItemsControl.ItemTemplate>
            </Controls:FluidItemsControl>
            <!--</ScrollViewer>-->
            <StackPanel Grid.Row="1"
                        Margin="0,2,0,2">
                <HyperlinkButton HorizontalAlignment="Right" x:Name="infoLabel"
                                 NavigateUri="http://www.twitter.com/andrejt"
                                 TargetName="_blank"
                                 BorderThickness="0"
                                 Content="Twedge 1.0 | @andrejt ">
                    <HyperlinkButton.Foreground>
                        <SolidColorBrush Color="{Binding UsernameColor, Source={StaticResource Theme}}" />
                    </HyperlinkButton.Foreground>
                </HyperlinkButton>
                <TextBlock x:Name="errorText"
                           Foreground="Red" />
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
